<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      .father {
        width: 300px;
        height: 300px;
        background-color: green;
      }
      .son {
        width: 150px;
        height: 150px;
        background-color: red;
      }
    </style>
  </head>
  <body>
    <div id="app">
      <div class="father" @click="fatherClick">
        <div class="son" @click.stop="sonClick"></div>
      </div>

      <form @submit.prevent="handleSubmit">
        <input type="text" />
        <input type="submit" />
      </form>

      <!-- <input type="text" @keyup.enter="handleClick" /> -->
      <input type="text" @keyup.13="handleClick" />
    </div>
    <!-- .stop 阻止事件冒泡 -->
    <!-- .prevent 阻止默认行为 -->

    <script src="../Vue.js"></script>
    <script>
      new Vue({
        el: "#app",
        data: {},
        methods: {
          fatherClick() {
            console.log("fatherClick");
          },
          sonClick() {
            // e.stopPropagation();
            console.log("sonClick");
          },
          handleSubmit() {
            console.log("handleSubmit");
          },
          handleClick(e) {
            // if (e.keyCode === 13) {
            //   console.log(123);
            // }
            // if (e.key === "Enter") {
            //   console.log(123);
            // }
            console.log(e.target.value);
          },
        },
      });
    </script>
  </body>
</html>
